package com.sdry.product.common.controller;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sdry.common.BaseController;
import com.sdry.common.TableDataInfo;
import com.sdry.product.common.entity.HalfProductStock;
import com.sdry.product.common.service.HalfProductStockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description 半成品库存
 * @Author chenBin
 * @Date 2020-03-23 15:18
 * @Version 1.0
 **/
@Controller
@RequestMapping(value = "/halfProduct")
public class HalfProductStockController extends BaseController {

    /**服务**/
    @Resource
    private HalfProductStockService halfProductStockService;

    /**
     * 页面展示
     * @return String
     */
    @RequestMapping(value = "showHalfProductStock")
    public String showHalfProductStock() {
        return "/product/common/halfStock";
    }

    /**
     * 分页查询半成品库存
     * @param halfProductStock
     * @return
     */
    @RequestMapping(value = "queryHalfProductStockPage")
    @ResponseBody
    public TableDataInfo queryHalfProductStockPage(HalfProductStock halfProductStock) {
        logger.info("分页查询半成品库存", JSONObject.toJSONString(halfProductStock));
        IPage<HalfProductStock> halfProductStockIPage = halfProductStockService.queryHalfProductStockPage(halfProductStock);
        return getDataTable(halfProductStockIPage.getRecords(),halfProductStockIPage.getTotal());
    }
}
